// pages/activity/nationalDay/components/RawardList/RawardList.js
const imgBaseUrl = "https://ustatic.hudongmiao.com/joymewApp/activity/nationalDay/"

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    awardObj: Object
  },

  /**
   * 组件的初始数据
   */
  data: {
    cardList: [{
        id: 'Award1',
        GiftImg: `${imgBaseUrl}gift1@v2.png`,
        GiftTitle: `${imgBaseUrl}title1.png`,
      },
      {
        id: 'Award2',
        GiftImg: `${imgBaseUrl}gift2.png`,
        GiftTitle: `${imgBaseUrl}title2@v1.png`,
      },
      {
        id: 'Award3',
        GiftImg: `${imgBaseUrl}gift3.png`,
        GiftTitle: `${imgBaseUrl}title3@v2.png`,
      },
      {
        id: 'Award4',
        GiftImg: `${imgBaseUrl}gift4.png`,
        GiftTitle: `${imgBaseUrl}title4@v2.png`,
      },
      {
        id: 'Award5',
        GiftImg: `${imgBaseUrl}gift5.png`,
        GiftTitle: `${imgBaseUrl}title5@v2.png`,
      },
      {
        id: 'Award6',
        GiftImg: `${imgBaseUrl}gift6.png`,
        GiftTitle: `${imgBaseUrl}title6.png`,
      },
      {
        id: 'Award7',
        GiftImg: `${imgBaseUrl}gift7.png`,
        GiftTitle: `${imgBaseUrl}title7.png`,
      }
    ],
    showCardList: []
  },
  observers: {
    'awardObj': function (awardObj) {
      const {
        list1,
        list2,
        list3,
        list4
      } = awardObj
      let cardList = this.data.cardList
      cardList[1].maxLen = list1.length;
      cardList[2].maxLen = list2.length;
      cardList[3].maxLen = list3.length;
      cardList[4].maxLen = list4.length;
      cardList[1].list = list1.slice(0, 10);
      cardList[2].list = list2.slice(0, 10);
      cardList[3].list = list3.slice(0, 10);
      cardList[4].list = list4.slice(0, 10);
      this.setData({
        showCardList: cardList
      })
    }
  },
  lifetimes: {
    attached() {
      const {
        list1,
        list2,
        list3,
        list4
      } = this.data.awardObj
      let cardList = this.data.cardList
      cardList[1].maxLen = list1.length;
      cardList[2].maxLen = list2.length;
      cardList[3].maxLen = list3.length;
      cardList[4].maxLen = list4.length;
      cardList[1].list = list1.slice(0, 10);
      cardList[2].list = list2.slice(0, 10);
      cardList[3].list = list3.slice(0, 10);
      cardList[4].list = list4.slice(0, 10);
      this.setData({
        showCardList: cardList
      })
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {

  }
})